<?php 
require 'Controller.php ';
require './admin/Model/VideoModel.php';
class VideoController extends Controller
{
	function __Construct()
	{
		parent::__Construct();
		$this->mod='videos';
		$this->model=new VideoModel();
	}
	function listvideos()
	{
		$data =$this->model->getList();
		$this->assign('videos',$data);
		$this->display(); 
	}
	function videoform()
	{
		$this->display(); 
	}
	function add1()
	{
		$data = $_POST;
		$result = $this->model->add1($data);
		if($result){
			echo '添加成功 <a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=video&m=listvideos'");
		}
		else{
			echo "添加失败！<br/>";
			echo "<a href='index.php?c=video&m=videoform'>返回</a>";
		}
	}
	function videomod()
	{
		$id = $_GET['id'];
		$result = $this->model->getVideoByID($id);
		$this->assign('video',$result);
		$this->display(); 
	}
	function update1()
	{
		$data = $_POST;
		$result = $this->model->update1($data);
		if($result){
			echo '更新成功 <a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=video&m=listvideos'");
		}
		else{
			echo "更新失败！<br/>";
			echo "<a href='index.php?c=video&m=videomod&id=".$data['id']."'>返回</a>";
		}
	}
	function delete1()
	{
		$id = $_GET['id'];
		$result = $this->model->delete1($id);
		if($result){
			echo '删除成功 <a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=video&m=listvideos'");
		}
		else{
			echo "删除失败！<br/>";
			echo "<a href='index.php?c=video&m=listvideos'>返回</a>";
		}
		
	}
}

?>

